package com.neusoft.neuhealth.controller;

import com.neusoft.neuhealth.po.Result;
import com.neusoft.neuhealth.po.bed.result.Pair;
import com.neusoft.neuhealth.po.room.RoomResult;
import com.neusoft.neuhealth.service.IBedService;
import com.neusoft.neuhealth.service.IRoomService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "房间管理接口")
@RestController
@RequestMapping("/room")
public class RoomController {
    @Autowired
    private IRoomService roomService;
    @Autowired
    private IBedService bedService;
    //  获取房间所有房间
    @Operation(summary = "获取房间所有房间")
    @GetMapping("/options")
    public Result<List<RoomResult>> options(){
        return roomService.options();
    }

    //获取指定房间的可用床位
    @Operation(summary = "获取指定房间的可用床位")

    @GetMapping("/{roomNumber}/beds")
    public Result<List<Pair>> freeBeds(@PathVariable String roomNumber){
        return bedService.selectFreeBeds(roomNumber);
    }
    //更新床位信息，将床位状态更新为空闲free
    @Operation(summary = "更新床位信息")

    @PutMapping("/{roomNumber}/bed/{bedNumber}/status")
    public Result updateBedStatus(@PathVariable Long roomNumber, @PathVariable Long bedNumber){
        return roomService.updateBedStatus(roomNumber, bedNumber);
    }
}
